{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "33bd7e31",
   "metadata": {},
   "source": [
    "* 本周主要内容：图像识别（人脸识别）\n",
    "* API-week4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1da47241",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 上周内容：\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6325323f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 本周内容\n",
    "* 1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c31b9e9a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n",
      "{'request_id': '1678938627,d0d11737-0f12-446f-b956-f6497aa03a59', 'time_used': 309, 'faces': [], 'image_id': 'Jp+zbor4TyR2+J7BwPrgFQ==', 'face_num': 0}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "通用物体和场景识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('C:/Users/ASUS/Desktop/labi.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\"image_base64\":img,\n",
    "          \"api_key\":\"6vjiue_XLkgKONsspkhkTI0m8JcmXI4b\",\n",
    "          \"api_secret\":\"msLjBfL1yjuIvmZawijxGoyA1BjuftPP\",\n",
    "          \"return_attributes\":\"gender,age,smiling,emotion,beauty\"\n",
    "}\n",
    "\n",
    "          \n",
    "request_url = request_url\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "if response:\n",
    "    print (response.status_code)\n",
    "    print (response.json())\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aa7158f9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0cc3ee6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
